<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>商家编辑</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<style type="text/css">
			#sfz_pic{position: relative;}/*opacity: 0;*/
			.upload,.upload1{position: absolute;top: 0;left: 0;width: 100%;height: 100%;opacity: 0;}
		</style>
		<style>
			.yanshi {
				height: 38px;
			    line-height: 1.3;
			    line-height: 38px\9;
			    border: 1px solid #e6e6e6;
			    background-color: #fff;
			    border-radius: 2px;
			    width: 211px;
			}
		</style>
	</head>

	<body>
		<form class="layui-form update_form" >
			<input type="hidden" name="id" value="{$data.id}" />
			<div class="layui-form-item">
				<label class="layui-form-label">商铺名称</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="agent_name" lay-verify="required" value="{$data.agent_name}" placeholder="商铺名称" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
    			<div class="renz_img " id="yyzz_pic" style="margin-left: 120px; margin-top: 20px;">
    				<input type="hidden" name="logo" id="thumb_1"  value="{$data.logo}" lay-verify="required" autocomplete="off" class="layui-input"/>
    				<input type="file" id="upload_1" class="upload1" style="width: 50%;height: 30%;" value="选择图片文件" multiple/>
					<span><img class='img_1' id='img_1' src="{$data.logo}" style="width: 150px;height: 150px;"></span>
    			</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label" >省市级代理商</label>
				<div class="layui-input-block" style="float: left; margin-right: 30px; margin-left: 0;">
					<select name="agency_id1" id="agency_id1" onchange="select_agency(this);" lay-ignore class="yanshi">
						{volist name="province" id="vo"}
						<option value="{$vo.id}" {if condition="$data.agency_id1 eq $vo.id" }selected{/if}>{$vo.user_name}</option>
						{/volist}
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">区域运营商</label>
				<div class="layui-input-block" style="float: left; margin-right: 30px; margin-left: 0;">
					<select name="agency_id2" id="agency_id2" lay-ignore class="yanshi">
						{volist name="yys" id="vo"}
						<option value="{$vo.id}" {if condition="$data.agency_id2 eq $vo.id" }selected{/if}>{$vo.user_name}</option>
						{/volist}
					</select>
				</div>
			</div>
			
			<div class="layui-form-item">				
				<label class="layui-form-label">行业分类</label>
				<div  class="layui-input-block"  style="float: left; margin-right: 20px; margin-left: 0;">
					<select name="trade_type" onchange="select_trade(this);" lay-ignore class="yanshi" lay-filter="sel_1" lay-verify="required">
						{volist name="typelist" id="vo"}
						<option value="{$vo.id}" {if condition="$data.trade_type==$vo.id" } selected="selected" {/if}>{$vo.type_name}</option>
						{/volist}
					</select>
				</div>				
			</div>
			<div class="layui-form-item">
			
				<label class="layui-form-label">行业二级分类</label>
				<div class="layui-input-block"  style="float: left; margin-right: 20px; margin-left: 0;" >
					<select id="trade_type2" name="trade_type2" lay-ignore class="yanshi" lay-filter="sel_1"  lay-verify="required">
			        	{if $type2}
			        	<option value="{$type2['id']}">{$type2['type_name']}</option>
			        	{else}
			        	<option value="0">选择行业</option>
			        	{/if}
					</select>
				</div>			
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">联系人</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="user_name" lay-verify="required" value="{$data.user_name}" placeholder="联系人" autocomplete="off" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">联系电话</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="mobile" lay-verify="required" value="{$data.mobile}" placeholder="联系电话" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">店铺性质</label>
				<div class="layui-input-block" style="float: left; margin-right: 20px; margin-left: 0;">
					<select name="store_property" id='store_property' lay-verify="required" lay-filter="sel_1">
						<option value=1 {if $data.store_property == 1}selectd{/if}>个人</option>
						<option value=2 {if $data.store_property == 2}selectd{/if}>企业</option>
						<option value=3 {if $data.store_property == 3}selectd{/if}>个体户</option>
					</select>
				</div>
			</div>


			<!--
            	作者：xx
            	时间：2018-05-28
            	描述：签约内容
            -->
            <div class="shxx_title">签约信息</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商户号</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="cb_login_name" value="{$data.cb_login_name}" lay-verify="required"  placeholder="商户号" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">员工密钥</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="cb_clerk" value="{$data.cb_clerk}" lay-verify="required"  placeholder="员工密钥" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">银行费率</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="cb_huilu" value="{$data.cb_huilu}" lay-verify="required"  placeholder="银行费率" autocomplete="off" class="layui-input">
				</div>
			</div>
			
			<!--
            	作者：xx
            	时间：2018-05-28
            	描述：银行信息
            -->
    		<div class="shxx_title">资金结算账号(用于结算收款资金的银行帐号)</div>
            <div class="layui-form-item">
				<label class="layui-form-label">账户名</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="account_name" value="{$ad.account_name}" readonly lay-verify="required"  placeholder="账户名" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">银行帐号</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="bank_account" value="{$ad.bank_account}" readonly lay-verify="required" placeholder="银行帐号" autocomplete="off" class="layui-input">
					<p class="redtip">用于结算收款资金的银行账号。务必与账户名对应，否则将影响资金到账</p>
				</div>				
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">开户银行</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="open_bank" value="{$ad.open_bank}" readonly lay-verify="required"  placeholder="开户银行" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">支行名称</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="branch_name" value="{$ad.branch_name}" readonly  lay-verify="required"  placeholder="支行名称" autocomplete="off" class="layui-input">
					<p class="redtip">支行名称为必填项</p>
				</div>			
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">支行所在地区</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="branch_address" value="{$ad.branch_address}" readonly lay-verify="required"  placeholder="支行所在地区" autocomplete="off" class="layui-input">
					<p class="redtip">支行所在地区为必填项</p>
				</div>				
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">预留手机号码</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="yl_mobile" value="{$ad.yl_mobile}" readonly lay-verify="required"  placeholder="预留手机号码" autocomplete="off" class="layui-input">

				</div>			
			</div>	
			<div class="layui-form-item update_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit type="button" lay-filter="submit_from">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
</html>
<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
<script src="__PUBLIC__/static/layui/layui.all.js"></script>
<script>
		//图片上传
		layui.use(['form','upload'], function(){
  		var $ = layui.jquery,upload = layui.upload,form = layui.form;
  		
  		var uploadInst_1 = upload.render({
			elem: '#upload_1'
		    ,auto: false //选择文件后不自动上传
		    ,choose: function(obj){
			    //将每次选择的文件追加到文件队列
			    var files = obj.pushFile();
			    //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
			    obj.preview(function(index, file, result){
			    	$('#img_1').attr('src', result); //图片链接（base64）
			    	var sendData = result.substring(result.indexOf(";base64,")+8);
			    	$.post("{:url('oem/index/upload')}",{value:sendData},function(data){ 
	                            if(data.code == '200'){  
	                            	$('#thumb_1').val(data.url);
	                            }else{  
	                                layer.msg(data.msg);
	                            }  
                    		});
				    });
				}
			    ,url: "{:url('oem/index/upload')}"
			    ,accept:'images'
			});
			//监听表单提交
			form.on('submit(submit_from)', function(data){
				tijiao();
	  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
			});
			
			
		});
		
			layui.use('form', function() {
				var form = layui.form;
				
				//监听表单提交
				form.on('submit(submit_from)', function(data){
					edit_agency();
		  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
				});
			});
			//提交表单
			function edit_agency() {
				$.ajax({
					type: "post",
					url: "{:url('oem/accounts/edit_agent')}",
					data: $('.layui-form').serialize(), //表单数据
					success: function(data) {
						if(data.code == 200) {
							layer.msg('修改成功', {
								icon: 1,
								time: 1500 //2秒关闭（如果不配置，默认是3秒）
							}, function() {
								window.parent.location.reload();
								var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
								parent.layer.close(index);
							});
						} else {
							layer.msg('修改失败！'); //保存成功提示
						}
					},
					error: function(data) {
						var a = data;
					}
				});

			}
			
			function select_trade(obj){
				var trade_id=$(obj).val();
				var lay = layer.load(0, {shade: false,time: 1.5 * 1000});
				$.ajax({
						type: 'post',
						url: "{:url('index/get_trades')}",
						data: {
							trade_id:trade_id
						},
						success: function(data) {
							var list=data.data;
							if(list){
								var html="<option value='0'>选择行业</option>";
								for(var i=0;i<list.length;i++){
									var trade=list[i];
									html+="<option value="+trade['id']+">"+trade['type_name']+"</option>";
								}
								$("#trade_type2").html(html);
		
							}
						}
				})
				
			}
			$("#trade_type").val('{$data.trade_type}');
			$("#trade_type2").val('{$data.trade_type2}');
			
			
			
			function select_agency(obj){
				var agency_id1=$(obj).val(); 
				var lay = layer.load(0, {shade: false,time: 1.5 * 1000});
				$.ajax({
						type: 'post',
						url: "{:url('accounts/get_agency_id1')}",
						data: {
							agency_id1:agency_id1
						},
						success: function(data) {  
							var list=data.data;
							if(list){
								var html="<option value='0'>选择区域运营商</option>";
								for(var i=0;i<list.length;i++){
									var trade=list[i]; 
									html+="<option value="+trade['id']+">"+trade['user_name']+"</option>";
								}
								$("#agency_id2").html(html);
		
							}
						}
				})
			}
		</script>
	</body>

</html>